
class LoginController {
    constructor($scope,$rootScope,$q,$state,$timeout,UserService){
        Object.assign(this,{$scope,$rootScope,$q,$state,$timeout,UserService});
        this.username = null;
        this.password = null;
        this.routeAterLogined="dashboard.entrance";
    }
    login(){
        //将this 赋值给self，在子函数中使用this，是引用子函数的this对象。
        let self = this;
        this.UserService.login(this.username,this.password).then(_success).catch(_error);
        function _success(data) {
            if(data.is_modified_password==0){//未修改过密码
                self.$state.go("dashboard.accountdash.pwd");
                return;
            }
            if(self.$state.prev){
                self.$state.go(self.$state.prev.state,self.$state.prev.params);
                self.$state.prev = null;
                return;
            }else{
                self.$state.go(self.routeAterLogined);
                return;
            }
        }
        function _error(message) {

        }
    }


}
LoginController.$inject = ["$scope","$rootScope", "$q",'$state', '$timeout',"UserService"];

export default LoginController;